#include <iostream>
using namespace std;

int a[10] = { 10,9,11,30,21,25,7,3,3,2 };
int b[10];

void Merge(int a[], int s, int m, int e, int tmp[])
{
	int p1 = s;
	int p2 = m + 1;
	int p = 0;
	while (p1 <= m && p2 <= e)
	{
		if (a[p1] < a[p2])
			tmp[p++] = a[p1++];
		else
			tmp[p++] = a[p2++];
	}
	while (p1 <= m)
		tmp[p++] = a[p1++];
	while (p2 <= m)
		tmp[p++] = a[p2++];
	for (int i = 0; i < p; ++i)
		a[s + i] = tmp[i];
}

void MergeSort(int a[], int s, int e, int tmp[])
{
	if (s < e)
	{
		int m = s + (e - s) / 2;
		MergeSort(a, s, m, tmp);
		MergeSort(a, m + 1, e, tmp);
		Merge(a, s, m, e, tmp);
	}
}

int main()
{
	int n = sizeof(a) / sizeof(int);
	MergeSort(a, 0, n - 1, b);
	for (int i = 0; i < n; ++i)
		cout << a[i] << " ";
	cout << endl;
	return 0;
}